<template>
  <div class="newsContent">
    <h3 class="title">{{ newsList.title }}</h3>
    <p class="subtitle">
      <span>{{ newsList.add_time|dataFormat }}</span>
      <span>点击次数： {{ newsList.click }}次</span>
    </p>
    <hr>
    <div class="content" v-html="newsList.content"></div>
    <comments :id='this.id'></comments>
  </div>
</template>
<script>
import { Toast } from "mint-ui";
import comments from "../subcomponents/comments.vue";
export default {
  components: {
    'comments':comments
  },
  
  created() {
    this.getData();
  },
  data() {
    return {
      id: this.$route.params.id,
      newsList: []
    };
  },
  methods: {
    getData() {
      this.$http.get("api/getnew/" + this.id).then(data => {
        // console.log(data.body);
        if (data.body.status === 0) {
          this.newsList = data.body.message[0];
          Toast("请求数据成功");
        } else {
          Toast("请求数据错误");
        }
      });
    }
  }
};
</script>
<style lang="scss">
.newsContent {
  padding: 4px;
  .title {
    font-size: 14px;
    color: red;
    text-align: center;
  }
  .subtitle {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: #26a2ff;
  }
  .content {
  }
}
</style>
